/obj/test/matrix
	var/Matrix
		// Two arbitrary 2x2 matrices.
		A = new(2)
		B = new(2)
		// 2x2 Identity matrix
		I

	New()
		A.Populate(1, 2, 3, 4)
		B.Populate(-5, 6, 7, 8)
		I = Matrix.Identity(2)

	proc
		AssertMatrixEqual(Matrix/M, Matrix/N)
			Assert(M.Equals(N), "Matrix assertion failed.\nM: [M.ToString()]\nN: [N.ToString()]")

	verb
		Add_test()
			var/Matrix/M = new/Matrix(2)
			M.Populate(-4, 8, 10, 12)
			AssertMatrixEqual(M, A.Add(B))

		Determinant_test()
			AssertEqual(A.Determinant(), -2)
			AssertEqual(I.Determinant(), 1)

		Equals_test()
			Assert(A.Equals(A.Copy()))

		Inverse_test()
			var/Matrix
				C 	= A.Inverse()
				AC	= A.Multiply(C)
			AssertMatrixEqual(AC, I)

		Multiply_test()
			var/Matrix
				AB	= A.Multiply(B)
				AI 	= A.Multiply(I)
				expect = new(2)
			expect.Populate(9, 22, 13, 50)
			AssertMatrixEqual(AB, expect)
			AssertMatrixEqual(A, AI)

		Transpose_test()
			var/Matrix
				M = new(2)
				At = A.Transpose()
			M.Populate(1, 3, 2, 4)
			AssertMatrixEqual(M, At)
			AssertMatrixEqual(I, I.Transpose())

		Value_test()
			var/Matrix/M = A.Copy()
			M.SetValue(1, 1, 9)
			AssertEqual(M.GetValue(1, 1), 9)
			M.SetValue(1, 2, 10)
			AssertEqual(M.GetValue(1, 2), 10)

